home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / SNIP9_91.ARJ / NORESET.C < prev    next >
C/C++ Source or Header  |  1990-06-25  |  2KB  |  39 lines

  1. /* code to disable <Ctrl><Alt><Del>.                                */
  2.  
  3. #include <dos.h>
  4.  
  5. #define CTRLALT        (0x08|0x04) /* bit flags set in kbstat()     */
  6. #define DELSCAN        0x53        /* keyboard scan code for <Del>  */
  7. #define KEYPORT        0x60        /* keyboard scan code port       */
  8. #define CONTROLLERPORT 0x20        /* interrupt controller port     */
  9. #define kbstat()       peekb(0,0x417)  /* BIOS data area - kb flags */
  10.  
  11. #define keyport()      inportb(KEYPORT)
  12.         /* macro that returns the scancode of the key that caused   */
  13.         /* the interrupt                                            */
  14.  
  15. #define install()      (oldkbisr=getvect(0x09),setvect(0x09,newkbisr))
  16.         /* installation macro, installs newkbisr() in the keyboard  */
  17.         /* interrupt chain                                          */
  18.  
  19. #define remove()       setvect(0x09,oldkbisr)
  20.         /* removal macro, call to remove newkbisr() from interrupt  */
  21.         /* chain.  oldkbisr()  must be removed before program ends  */
  22.  
  23. void interrupt (*oldkbisr)(void);  /* address of old keyboard ISR   */
  24.  
  25. void interrupt newkbisr(void)
  26. {
  27.    if((keyport()==DELSCAN)&&(kbstat()&CTRLALT))
  28.    {
  29.        char kbin=inportb(KEYPORT+1);  /* reset keyboard */
  30.        outportb(KEYPORT+1,kbin|0x80);
  31.        outportb(KEYPORT+1,kbin);
  32.        disable();
  33.        outportb(CONTROLLERPORT,0x20); /* tell controller to shut up */
  34.        enable();
  35.    }
  36.    else
  37.       oldkbisr();  /* chain to old keyboard isr */
  38. }
  39.